@echo off

echo installing packages...
pip install -r ./requirements.txt

pause

cd  ./src

set "dir1=filesUpload"
set "dir2=filesDownload"
set "dir3=temp"

if exist "%dir1%" (
    echo %dir1% exists. Clearing contents...
    del /q "%dir1%\*"
    if errorlevel 1 (
        echo Error clearing %dir1%.
        exit /b 1
    )
) else (
    echo %dir1% does not exist. Creating %dir1%...
    mkdir "%dir1%"
    if errorlevel 1 (
        echo Error creating %dir1%.
        exit /b 1
    )
)

if exist "%dir2%" (
    echo %dir2% exists. Clearing contents...
    del /q "%dir2%\*"
    if errorlevel 1 (
        echo Error clearing %dir2%.
        exit /b 1
    )
) else (
    echo %dir2% does not exist. Creating %dir2%...
    mkdir "%dir2%"
    if errorlevel 1 (
        echo Error creating %dir2%.
        exit /b 1
    )
)

if exist "%dir3%" (
    echo %dir3% exists. Clearing contents...
    del /q "%dir3%\*"
    if errorlevel 1 (
        echo Error clearing %dir3%.
        exit /b 1
    )
) else (
    echo %dir3% does not exist. Creating %dir3%...
    mkdir "%dir3%"
    if errorlevel 1 (
        echo Error creating %dir3%.
        exit /b 1
    )
)

pause

cd ../

start RUN.bat